import {
	defineStore
} from 'pinia';

export const useToken = defineStore('userStores', {
	state: () => {
		return {
			unread: 0,
			token: '',
			userInfo: {}
		};
	},
	unistorage: true,
	actions: {
		setLogin(value) {
			this.token = value.token;
			this.userInfo = value
		},
		updateToken(value){
			this.token = value;
		},
		setUnread(value) {
			this.unread = value
		},
		clearToken() {
			this.token = null;
			this.userInfo = {}
		},
		clearUnread() {
			this.unread = 0
		},
		setAvatar(value) {
			this.avatar = value
		}
	},
	getters: {
		getToken() {
			return this.token;
		},
		getUnread() {
			return this.unread;
		},
		getUser() {
			return this.userInfo;
		},
		getAvatar() {
			return this.avatar
		},
		getPhone(){
			return this.userInfo.user_phone
		}
	},
});
